<template>
  <div>
    <el-row class="add">
      <div>
        <el-button icon="el-icon-plus" size="small" plain type="primary">创建</el-button>
      </div>
    </el-row>
    <el-table
      :data="menuList"
      style="width: 100%;margin-bottom: 20px;"
      row-key="id"
      border
      lazy
      :load="load"
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
    >
      <el-table-column prop="permission_name" label="菜单名称" />
      <el-table-column prop="route" label="菜单地址" />
      <el-table-column prop="permission_mark" label="权限标识" />
      <el-table-column prop="icon" label="图标">
        <template slot-scope="{row}">
          <svg-icon :icon-class="row.icon" />
        </template>
      </el-table-column>
      <el-table-column prop="component" label="组织路径" />
      <!-- <el-table-column prop="type" label="类型">
        <template slot-scope="{row}">
          <span>{{ row.type === 1 ? '菜单' : '按钮' }}</span>
        </template>
      </el-table-column> -->
      <el-table-column prop="hidden" label="是否显示">
        <template slot-scope="{row}">
          <el-switch v-model="row.hidden" inactive-text="否" active-text="是" :active-value="1" :inactive-value="2" />
        </template>
      </el-table-column>
      <el-table-column prop="updated_at" label="添加时间" />
      <el-table-column label="操作">
        <template slot-scope="{row}">
          <el-button type="primary" circle icon="el-icon-edit" @click="editMenu(row.id)" />
          <el-button v-if="row.type===1" type="warning" circle icon="el-icon-plus" @click="openedit(row.id)" />
          <el-button type="danger" circle icon="el-icon-delete" @click="delArticle(row.id)" />
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getMenuListApi } from '@/api/permission/menu'
export default {
  name: 'Menu',
  data() {
    return {
      menuList: []
    }
  },
  created() {
    this.getMenuList()
  },
  methods: {
    async getMenuList() {
      const res = await getMenuListApi()
      this.menuList = res
    }
  }

}
</script>

<style>
.add{
  margin: 10px;
  display: flex;
  justify-content: flex-end;
}
</style>
